<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'report-form',
	'enableAjaxValidation'=>false,
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

        <div class="row">
            <span class="column">
		<?php echo $form->LabelEx($model,'date'); ?>
		<?php $this->widget('zii.widgets.jui.CJuiDatePicker',
              array(
                    'model'=>$model,
                    'attribute'=>"date",
                    'htmlOptions'=>array('value'=>(!empty($model->date))?(is_numeric($model->date))?date('d/m/Y',$model->date):$model->date:date('d/m/Y')),
                    'options'=>array('dateFormat'=>'dd/mm/yy'),
                   )
             );
?>
            </span>
            <span class="column">
                <?php echo $form->LabelEx($model,'type') ?>
                <?php echo $form->TextField($model, 'type'); ?>
            </span>
	</div>

	<div class="row clear">
            
            <span class="column">
                <?php echo $form->LabelEx($model,'title') ?>
                <?php echo $form->TextField($model, 'title'); ?>
            </span>
            <span class="column">
                <?php echo $form->LabelEx($model,'attn') ?>
                <?php echo $form->TextField($model, 'attn'); ?>
            </span>
        </div>
        <div class="row clear">
            <?php echo $form->LabelEx($model,'remark') ?>
            <?php echo $form->TextField($model, 'remark',array('size'=>'48')); ?>
        </div>

	<div class="row buttons" id="action">
        <?php
        	$this->widget('zii.widgets.jui.CJuiButton',array(
        		'name'=>'submit',
        		'caption'=>($model->isNewRecord)?'Save':'Update',
        		'value'=>"submit",
        	));
        ?>
    </div>

<?php $this->endWidget(); ?>

</div><!-- form -->
<?php
$cs = Yii::app()->getClientScript();
$reportViewURL = CHtml::normalizeUrl(array('view'));
$script =<<<EOD
$.report_form_afterSubmit = {
    afterSubmit:function(data){
        window.location = "$reportViewURL?id="+data.id;
    }
};
$('#report-form [type=submit]').click(function(){
	var form = $.extend($.simplelogform,$.report_form_afterSubmit);
	form.Submit($('#report-form'));
	return false;
});
EOD;
$cs->registerScript("report#form",$script);
?>